package com.bk.dao.hibernateimpl;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.bk.dao.UserDaoHibernate;
import com.bk.model.User;
import com.bk.utils.HibernateUtils;

public class UserHibernateImpl implements UserDaoHibernate {

	/*
	 * 增加用户
	 */
	@Override
	public void add(User user) {
		Session session = HibernateUtils.getCurrentSession();
		if (session != null) {
			Transaction transaction = session.getTransaction();
			transaction.begin();

			session.save(user);
			transaction.commit();
			session.close();
		}

	}

	/*
	 * 更具id删除用户
	 */
	@Override
	public void delete(String id) {
		Session session = HibernateUtils.getCurrentSession();
		if (session != null) {
			Transaction transaction = session.getTransaction();
			transaction.begin();

		} else {
			System.out.println("session为空");
		}

	}

}
